package org.batyrov.equery.terminal;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.BufferStrategy;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.Calendar;

/**
 * Created by IntelliJ IDEA.
 * User: sulic
 * Date: 27.02.2010
 * Time: 23:57:13
 * To change this template use File | Settings | File Templates.
 */
public class Main extends Frame {
    private static boolean done = true;

    @Override
    public void paint(Graphics g) {
        Graphics2D graphics2D = (Graphics2D) g;
        //graphics2D.setBackground(Color.BLUE);
        graphics2D.drawString("Java 2D", 50, 50);
    }

    /*private void render(Graphics g) {
        Calendar.getInstance().setTimeInMillis(System.currentTimeMillis());
        while (done) {
            Graphics2D graphics2D = (Graphics2D) g;
            graphics2D.setBackground(Color.BLUE);
            graphics2D.drawString("Java 2D", 50, 50);
            graphics2D.fillRect(0, 0, 1024, 768);
            graphics2D.setPaint(new Color(28, 140, 88));
            Thread.yield();
        }
    }*/

    public static void main(String[] args) {
        Main f = new Main();
        //f.setIgnoreRepaint(true);
        //Canvas canvas = new Canvas();
        //canvas.setSize(1366, 768);
        f.addWindowListener(new WindowListener() {
            @Override
            public void windowOpened(WindowEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }

            @Override
            public void windowClosed(WindowEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void windowIconified(WindowEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void windowDeiconified(WindowEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void windowActivated(WindowEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void windowDeactivated(WindowEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
            }
        });
        f.setSize(1000, 600);
        f.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
                    done = false;
            }
        });
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice graphicsDevice = ge.getDefaultScreenDevice();
        //f.setVisible(false);
        f.setUndecorated(true);
        f.setVisible(true);
        GraphicsConfiguration gc = graphicsDevice.getDefaultConfiguration();
        //f.createBufferStrategy(2);
        //BufferStrategy buffer = f.getBufferStrategy();
        //BufferedImage bi = gc.createCompatibleImage(1366, 1768);
        // f.pack();
        if (graphicsDevice.isFullScreenSupported()) {
            graphicsDevice.setFullScreenWindow(f);
            //DisplayMode displayMode = graphicsDevice.getDisplayMode();
            //graphicsDevice.setDisplayMode(new DisplayMode(1366, 768, 32, 60));
        }
        //f.render();

    }
}
